package com.magnificent.atlantis.client.ui.planner;

import com.magnificent.atlantis.client.event.EventDispatcher;
import com.magnificent.atlantis.client.event.EventDispatcherListener;
import com.magnificent.atlantis.client.event.EventType;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

/**
 * User: Babanin
 * Date: 13.02.2009
 * Time: 13:09:39
 */
public abstract class PlannerPanel extends JPanel implements EventDispatcherListener {
    protected PlannerData plannerData;

    private static List<PlannerPanel> plannerPanelList = new ArrayList<PlannerPanel>();

    public PlannerPanel(PlannerData plannerData) {
        this(plannerData, null);
    }

    public PlannerPanel(PlannerData plannerData, List<EventType> eventTypes) {
        this.plannerData = plannerData;
        plannerPanelList.add(this);

        if (eventTypes == null) {
            EventDispatcher.getInstance().addListener(this);
        } else {
            EventDispatcher.getInstance().addListener(eventTypes, this);
        }
    }

    public abstract void closing();

    public PlannerData getPlannerData() {
        return plannerData;
    }

    public static List<PlannerPanel> getPlannerPanelList() {
        return plannerPanelList;
    }
}
